<?php

/**
 * This is the model class for table "site_administrator_privilege".
 *
 * The followings are the available columns in table 'site_administrator_privilege':
 * @property string $administrator_privilege_id
 * @property string $administrator_privilege_administrator_group_id
 * @property string $administrator_privilege_administrator_menu_id
 * @property string $administrator_privilege_action_create
 * @property string $administrator_privilege_action_update
 * @property string $administrator_privilege_action_delete
 * @property string $administrator_privilege_action_publish
 * @property string $administrator_privilege_action_order_by
 * @property string $administrator_privilege_action_activate
 * @property string $administrator_privilege_action_process
 *
 * The followings are the available model relations:
 * @property SiteAdministratorGroup $administratorPrivilegeAdministratorGroup
 * @property SiteAdministratorMenu $administratorPrivilegeAdministratorMenu
 */
class site_administrator_privilege extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return site_administrator_privilege the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'site_administrator_privilege';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('administrator_privilege_administrator_group_id, administrator_privilege_administrator_menu_id', 'length', 'max' => 10),
            array('administrator_privilege_action_create, administrator_privilege_action_update, administrator_privilege_action_delete, administrator_privilege_action_publish, administrator_privilege_action_order_by, administrator_privilege_action_activate, administrator_privilege_action_process', 'length', 'max' => 1),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('administrator_privilege_id, administrator_privilege_administrator_group_id, administrator_privilege_administrator_menu_id, administrator_privilege_action_create, administrator_privilege_action_update, administrator_privilege_action_delete, administrator_privilege_action_publish, administrator_privilege_action_order_by, administrator_privilege_action_activate, administrator_privilege_action_process', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_administrator_privilege_to_administrator_group' => array(self::BELONGS_TO, 'site_administrator_group', 'administrator_privilege_administrator_group_id'),
            'rel_administrator_privilege_to_administrator_menu' => array(self::BELONGS_TO, 'site_administrator_menu', 'administrator_privilege_administrator_menu_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'administrator_privilege_id' => 'Administrator Privilege',
            'administrator_privilege_administrator_group_id' => 'Group',
            'administrator_privilege_administrator_menu_id' => 'Administrator Menu',
            'administrator_privilege_action_create' => 'Action Create',
            'administrator_privilege_action_update' => 'Action Update',
            'administrator_privilege_action_delete' => 'Action Delete',
            'administrator_privilege_action_publish' => 'Action Publish',
            'administrator_privilege_action_order_by' => 'Action Order By',
            'administrator_privilege_action_activate' => 'Action Activate',
            'administrator_privilege_action_process' => 'Action Process',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('administrator_privilege_id', $this->administrator_privilege_id, true);
        $criteria->compare('administrator_privilege_administrator_group_id', $this->administrator_privilege_administrator_group_id, true);
        $criteria->compare('administrator_privilege_administrator_menu_id', $this->administrator_privilege_administrator_menu_id, true);
        $criteria->compare('administrator_privilege_action_create', $this->administrator_privilege_action_create, true);
        $criteria->compare('administrator_privilege_action_update', $this->administrator_privilege_action_update, true);
        $criteria->compare('administrator_privilege_action_delete', $this->administrator_privilege_action_delete, true);
        $criteria->compare('administrator_privilege_action_publish', $this->administrator_privilege_action_publish, true);
        $criteria->compare('administrator_privilege_action_order_by', $this->administrator_privilege_action_order_by, true);
        $criteria->compare('administrator_privilege_action_activate', $this->administrator_privilege_action_activate, true);
        $criteria->compare('administrator_privilege_action_process', $this->administrator_privilege_action_process, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}